﻿using Entity.Finance.DTO.MonthWages;
using Entity.Finance.DTO.MonthWagesItem;
using Entity.Finance.View.MonthWages;
using Entity.Finance.View.MonthWagesItem;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Service;
using Service.System;

namespace AnQinManagermentBackendAPI.Controller.Finance
{
    /// <summary>
    /// 工资
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    [Authorize]
    [AllowAnonymous]
    public class MonthWagessController : ControllerBase
    {
        /**
         * 业务接口
         */
        private readonly MonthWagesService _service;

        /**
         * 构造函数注入
         */
        public MonthWagessController(MonthWagesService service)
        {
            _service = service;
        }

        /// <summary>
        /// 获取列表
        /// </summary>
        [HttpGet]
        [ProducesResponseType(typeof(MonthWagesView), 200)]
        public async Task<IActionResult> GetMonthWagesList([FromQuery] MonthWagesSearchDTO model)
        {
            var response = await _service.GetMonthWagesList(model);
            return StatusCode(response.Status, response);
        }
        
        /// <summary>
        /// 获取列表
        /// </summary>
        [HttpGet("Item")]
        [ProducesResponseType(typeof(MonthWagesItemView), 200)]
        public async Task<IActionResult> GetMonthWagesItemList([FromQuery] MonthWagesItemSearchDTO model)
        {
            var response = await _service.GetMonthWagesItemList(model);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 新增
        /// </summary>
        [HttpPost]
        public async Task<IActionResult> AddMonthWages([FromBody] MonthWagesAddDTO model)
        {
            var response = await _service.AddMonthWages(model);
            return StatusCode(response.Status, response);
        }

        ///// <summary>
        ///// 修改
        ///// </summary>
        //[HttpPut]
        //public async Task<IActionResult> PutMonthWages([FromBody] MonthWagesUpdateDTO model)
        //{
        //    var response = await _service.PutMonthWages(model);
        //    return StatusCode(response.Status, response);
        //}

        /// <summary>
        /// 删除
        /// </summary>
        [HttpDelete]
        public async Task<IActionResult> DeleteMonthWages([FromQuery] string Id)
        {
            var response = await _service.DeleteMonthWages(Id);
            return StatusCode(response.Status, response);
        }

    }
}
